package com.hnkywl.sts.service.htdygl;

import com.hnkywl.sts.dao.htdygl.HtdyDao;
import com.hnkywl.sts.dao.htdygl.HtwbDao;
import com.hnkywl.sts.dao.htdygl.HtysdyDao;
import com.hnkywl.sts.entity.htgl.Ht;
import com.hnkywl.sts.entity.htgl.Htdy;
import com.hnkywl.sts.entity.htgl.Htwb;
import com.hnkywl.sts.entity.htgl.Htys;
import com.hnkywl.sts.util.BaseUtils;
import net.ruixin.orm.hibernate.Page;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: nianjunyan
 * Date: 13-4-17
 * Time: 上午11:44
 * To change this template use File | Settings | File Templates.
 */
@Service
public class HtwbService {

    // 合同文本dao
    private HtwbDao htwbDao;

    @Autowired
    public void setHtwbDao(HtwbDao htwbDao) {
        this.htwbDao = htwbDao;
    }

    /**
     * 查询合同类型
     *
     * @param htId
     * @return
     */
    public String findHtlx(String htId) {
        String sql = "select type from t_biz_ht where id =? and deleted=0";
        List htlxList = this.htwbDao.findBySQL(sql, htId);
        if (null != htlxList && htlxList.size() > 0) {
            return  htlxList.get(0).toString();
        }
        return null;
    }

    /**
     *  对数据库字段进行特殊处理
     * @param value
     * @return
     * @throws Exception
     */
    public  String getValue(String value) throws Exception {
        String ewXml="<?xml version=\"1.0\" encoding=\"GB2312\"?>\n";
        ewXml+="<aa><a>"+value+"</a></aa>";
        Element root = DocumentHelper.parseText(ewXml).getRootElement();
        Element usrName=root.element("a");
        return  usrName.getTextTrim();
    }

}
